package com.feiyu.shopsAndgoods.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.feiyu.shopsAndgoods.entity.DictGoodsEntity;
import com.feiyu.shopsAndgoods.service.DictGoodsService;
import com.feiyu.common.utils.PageUtils;
import com.feiyu.common.utils.R;


/**
 * @author wanghanbin
 * @email 1336891708@qq.com
 * @date 2021-04-03 12:36:05
 */
@RestController
public class DictGoodsController {
    @Autowired
    private DictGoodsService dictGoodsService;

    /**
     * 获取全部商品标签
     */
    @RequestMapping("/openFeiyu/getAllGoodsTag")
    //@RequiresPermissions("product:dictgoods:list")
    public R list(@RequestBody Map<String, Object> params) {
        PageUtils page = dictGoodsService.queryPage(params);
        return R.ok().put("data", page);
    }

    /**
     * 精确查找商品标签
     */
    @PostMapping("/openFeiyu/getGoodsTagNameByTagId")
    public R getGoodsTagNameByTagId(@RequestBody DictGoodsEntity dictGoodsEntity) {
        DictGoodsEntity entity = dictGoodsService.getById(dictGoodsEntity.getDictGoodsId());
        if (entity == null) {
            return R.error("未查询到该标签").put("data", null);
        }
        return R.ok("查询成功").put("data", entity);
    }
}
